package ru.nlezhnev.utils;

import java.io.ByteArrayInputStream;

import flex.messaging.io.SerializationContext;
import flex.messaging.io.amf.ASObject;
import flex.messaging.io.amf.Amf3Input;

public class RequestDecoder {
	public static ASObject decode(byte[] data) {
		try {
			SerializationContext sc = SerializationContext.getSerializationContext();
			sc.instantiateTypes = false;
			Amf3Input a = new Amf3Input(sc);
			
			ByteArrayInputStream byteStream = new ByteArrayInputStream(data);
			a.setInputStream(byteStream);
			
			ASObject asObj = (ASObject)a.readObject();
			return asObj;
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return null;
	}
}
